<template>
  <div class="exception">
    <img :src="getImageUrl('404')" />
    <el-button class="btn-home" @click="goHome">返回上一个页面</el-button>
  </div>
</template>

<script setup>
import { useRouter } from "vue-router";
const router = useRouter();
const getImageUrl = (img) => {
  // console.log(img)
  return new URL(`../assets/images/${img}.png`, import.meta.url).href;
};

const goHome = () => {
  //   router.push({ name: "home" });
  router.go(-2);
};
</script>

<style lang="less" scoped>
/* 组件样式 */
</style>

<style lang="less" scoped>
.exception {
  position: relative;
  width: 100%;
  height: 100vh; /* 使容器高度占满视口高度 */
  display: flex;
  justify-content: center; /* 水平居中 */
  align-items: center; /* 垂直居中 */
}
img {
  position: absolute;
  top: 0;
  left: 0;
  width: 100%;
  height: 100%;
  object-fit: cover;
}
.btn-home {
  position: absolute;
  bottom: 20px;
}
</style>
